<?php

class Zend_Controller_Action_Helper_Generator extends Zend_Controller_Action_Helper_Abstract 
{
	public function direct($length = 8, $seeds = 'alpha')
	{
		$seedings['alpha'] = 'abcdefghijklmnopqrstuvwxyz';
		$seedings['numeric'] = '0123456789';
		
		$seeds = $seedings[$seeds];
		
		$random = "";
		$count = strlen($seeds);
		
		for ($x = 0; $x < $length; $x++)
		{
			$random .= $seeds[mt_rand(0, $count-1)];
		}
		
		return $random;
		
	}
	
	public function generateCurrentTime() {
		$sql_date_pattern = 'yyyy-MM-dd HH:mm:ss';
		$date_obj = new Zend_Date();
		$current_time = $date_obj->get($sql_date_pattern);
		return $current_time;
	}
	
	/**
	 * Convert date string into a string with given pattern.
	 * 
	 * @param $dateString
	 * @param $pattern
	 * @return return converted date string
	 */
	public function formatDate($dateString, $pattern) {
		$date = new Zend_Date(strtotime($dateString));
        return $date->toString($pattern);
	}
	
}